#include <util\AutomaticInstallation.au3>


Global $InstallProgramPath = "C:\Program Files\TeamViewer\Version5\TeamViewer.exe"
Global $InstallFolder      = "C:\Program Files\TeamViewer\Version5"
	
Global $SetupFile = "TeamViewer_Setup.exe"
Global $UninstallPath = "C:\Program Files\TeamViewer\Version5\uninstall.exe"
Main($InstallProgramPath, $InstallFolder, $SetupFile, $UninstallPath)

Func InstallImpl($SetupPath) 
	Dim $Title = ""
	
	RunSetupFile($SetupPath)

	$Title = "TeamViewer 5 Setup"
	$Text = "Welcome to TeamViewer"
	WinWaitActive($Title, $Text)
	ControlClick($Title, "", "[CLASS:Button; INSTANCE:2]")
	
	$Text = "Environment"
	WinWaitActive($Title, $Text)
	ControlClick($Title, "", "[CLASS:Button; INSTANCE:4]")
	ControlClick($Title, "", "[CLASS:Button; INSTANCE:2]")
	
	$Text = "License Agreement"
	WinWaitActive($Title, $Text)
	ControlClick($Title, "", "[CLASS:Button; INSTANCE:4]")
	ControlClick($Title, "", "[CLASS:Button; INSTANCE:5]")
	ControlClick($Title, "", "[CLASS:Button; INSTANCE:2]")

	$Text = "Choose installation type"
	WinWaitActive($Title, $Text)
	ControlClick($Title, "", "[CLASS:Button; INSTANCE:2]")
	
	$Text = "Access Control"
	WinWaitActive($Title, $Text)
	ControlClick($Title, "", "[CLASS:Button; INSTANCE:2]")
	
	$Text = "&Finish"
	WinWaitActive($Title, $Text)
	ControlClick($Title, "", "[CLASS:Button; INSTANCE:2]")
	
	WinWaitClose($Title)
	
	Return True
EndFunc

Func UninstallImpl($UninstallPath)
	
	Dim $Title = ""
	Run($UninstallPath)

	$Title = "TeamViewer 5 Uninstall"
	$Text = "&Uninstall"
	WinWaitActive($Title, $Text)
	ControlClick($Title, "", "[CLASS:Button; INSTANCE:4]")
	ControlClick($Title, "", "[CLASS:Button; INSTANCE:2]")
	
	$Text = "Uninstall was completed successfully."
	WinWaitActive($Title, $Text)
		
	Return True
EndFunc




